//Constants defines


print("SQVersion:"+_version_ + ",\ncharsize: "+_charsize_+",intsize: " +_intsize_ + ",floatsize: "+_floatsize_ +"\n");

glutInitDisplayMode(GLUT_DEPTH|GLUT_SINGLE|GLUT_RGBA);
glutInitWindowPosition(200,200);
glutInitWindowSize(300,300);
glutCreateWindow("SQGLUT Tutorial");
glutDisplayFunc("diaplay");
glutIdleFunc("diaplay");
glutReshapeFunc("ReSize");

//glutMainLoop();// If glutMainLoop() appears here the screen will stuck and display nothing.
function diaplay()
{
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
	glBegin(GL_TRIANGLES);
	glVertex3f(-0.5,-0.5,0.0);
	glVertex3f(0.5,0.0,0.0);
	glVertex3f(0.0,0.5,0.0);
	glEnd();
	glFlush();
}

function ReSize(w,h)
{
	if(h == 0)
		h = 1;

    local ratio = 1.0* w / h;
 
	// Reset the coordinate system before modifying
	glMatrixMode(GL_PROJECTION);	
	glLoadIdentity();	 
	// Set the viewport to be the entire window
  glViewport(0, 0, w, h);    
	// Set the correct perspective.	
	gluPerspective(45.0,ratio,1.0,1000.0);	
	glMatrixMode(GL_MODELVIEW);	
	glLoadIdentity();

	gluLookAt(0.0,0.0,5.0,
	0.0,0.0,-1.0,
	0.0,1.0,0.0);	
}
glutMainLoop();